package com.ruoyi.web.controller.feeset;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.feeset.domain.HouseFeeSet;
import com.ruoyi.feeset.service.IHouseFeeSetService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 费用设置Controller
 * 
 * @author hct
 * @date 2022-02-16
 */
@RestController
@RequestMapping("/feeset/feeset")
public class HouseFeeSetController extends BaseController
{
    @Autowired
    private IHouseFeeSetService houseFeeSetService;

    /**
     * 查询费用设置列表
     */
    @PreAuthorize("@ss.hasPermi('feeset:feeset:list')")
    @GetMapping("/list")
    public TableDataInfo list(HouseFeeSet houseFeeSet)
    {
        startPage();
        List<HouseFeeSet> list = houseFeeSetService.selectHouseFeeSetList(houseFeeSet);
        return getDataTable(list);
    }

    /**
     * 导出费用设置列表
     */
    @PreAuthorize("@ss.hasPermi('feeset:feeset:export')")
    @Log(title = "费用设置", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, HouseFeeSet houseFeeSet)
    {
        List<HouseFeeSet> list = houseFeeSetService.selectHouseFeeSetList(houseFeeSet);
        ExcelUtil<HouseFeeSet> util = new ExcelUtil<HouseFeeSet>(HouseFeeSet.class);
        util.exportExcel(response, list, "费用设置数据");
    }

    /**
     * 获取费用设置详细信息
     */
    @PreAuthorize("@ss.hasPermi('feeset:feeset:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(houseFeeSetService.selectHouseFeeSetById(id));
    }

    /**
     * 新增费用设置
     */
    @PreAuthorize("@ss.hasPermi('feeset:feeset:add')")
    @Log(title = "费用设置", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody HouseFeeSet houseFeeSet)
    {
        return toAjax(houseFeeSetService.insertHouseFeeSet(houseFeeSet));
    }

    /**
     * 修改费用设置
     */
    @PreAuthorize("@ss.hasPermi('feeset:feeset:edit')")
    @Log(title = "费用设置", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody HouseFeeSet houseFeeSet)
    {
        return toAjax(houseFeeSetService.updateHouseFeeSet(houseFeeSet));
    }

    /**
     * 删除费用设置
     */
    @PreAuthorize("@ss.hasPermi('feeset:feeset:remove')")
    @Log(title = "费用设置", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(houseFeeSetService.deleteHouseFeeSetByIds(ids));
    }


    /**
     * 查询费用设置列表
     */
    @PreAuthorize("@ss.hasPermi('feeset:feeset:list')")
    @GetMapping("/listNoPage")
    public AjaxResult getFeeSetListNoPage(HouseFeeSet houseFeeSet){
        List<HouseFeeSet> list = houseFeeSetService.selectHouseFeeSetList(houseFeeSet);
        return AjaxResult.success("查询成功", list);
    }
}
